package com.issoft.studentresitor.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.issoft.studentresitor.domain.pojo.Notice;

import com.issoft.studentresitor.domain.query.NoticeQuery;
import com.issoft.studentresitor.domain.vo.NoticeVo;
import com.issoft.studentresitor.mapper.NoticeMapper;
import com.issoft.studentresitor.service.INoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.issoft.studentresitor.utils.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author GJH
 * @since 2025-09-14
 */
@Slf4j
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {
    @Autowired
    private NoticeMapper noticeMapper;


    @Override
    public PageResult<NoticeVo> queryNoticePage(NoticeQuery query) {
        PageHelper.startPage(query.getPage(), query.getPageSize());
        Page<NoticeVo> page = noticeMapper.queryNoticePage(query);
        return new PageResult<>(page.getTotal(), page.getResult());
    }

    @Override
    public List<NoticeVo> queryNotice(String title, String noticeType, LocalDateTime publishTime) {
        List<NoticeVo> noticeVos = noticeMapper.queryNotice(title, noticeType, publishTime);
        log.info("模糊查询的公告信息为：{}", noticeVos);
        return noticeVos;
    }
}
